<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<button>点我</button>

<script>
  document.querySelector("button").onclick = function () {
    const fnName = "ym"+Math.random().toString(36).slice(2)+Date.now();
    window[fnName] = function(num){
      console.log(num);
    }
    const script = document.createElement("script");
    script.src = "http://xuyihan.com/info2?callback="+fnName;
    script.onload = function(){
      document.body.removeChild(script);
      delete window[fnName];
    }
    document.body.appendChild(script);
  }
</script>
</body>
</html>
